

local i_list = "19993 20023 20053 20083 20113 20143 20173 20017 20087 20157"

foreach i in `i_list' 3 { 

	global ver = `i'  
	do "Set globals.do"
	  
	capture log close
	log using "$log/16_03_variance_decomp_${ver}", text replace

	use "$temp\cleaned_obs_ver$ver.dta", clear
	drop if missing(spell)

	keep persnr spell year tentgelt 

	drop if year <= $syear 
	drop if year >= $eyear

	merge 1:1 persnr spell using "$temp\BeH_large", keep(3) nogen keepusing(betnr)
	merge m:1 betnr using "$temp/temp_betnr_$ver", keep(3) nogen

	gen ln_imp_w = log(tentgelt)

	compress
	keep persnr ln_imp_w betnr year firm_fe1 firm_fe2
		
	*Bias-corrected variance decomposition (estimates used in Table E3)
	di as text "BC V[ln(w)] FOR VER ${ver}: "
	tabstat ln_imp_w, stat(variance)
	corr firm_fe1 firm_fe2, cov
	di as text "BC V[psi] FOR VER  ${ver}: " r(cov_12)

	clear
	cap log close

 }




